-- appaer_frozen
-- created by zhuangsl
-- 怪物出现时概率冰冻

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 攻击时触发
    trigger = function(who, prop, arg)
        local grid = arg;

        -- 不是怪物
        if not grid:isMonster() then
            return false;
        end

        -- 加成触发概率
        local value = prop[3];
        local p = PropM.combine(who, "prop_force_add", prop[1]);
        if p[3] > 0 then
            value = PropM.apply(p, value);
        end

        -- 概率没发生
        if DungeonM.getRandSeed("appaer_frozen") % 1000 >= value then
            return false;
        end

        local condition = {
            ["id"] = PropM.getPropId("frozen"),
            ["end_round"] = CombatM.getRound() + prop[4] + 1,
        };
        -- 附加状态
        CombatStatusM.applyStatus(grid.monster, "frozen", condition);

        -- 尝试增加经验
        local props = PropM.fetchProps(who, "frozen_add_exp");
        for _, p in ipairs(props) do
            PropM.trigger(who, p[1], p[2]);
        end

        -- 触发特技发动事件
        EventMgr.fire(event.SPECIAL_SKILL_TRIGGER, { propId = prop[1], pos = grid:getPos() });

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};
